package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.controller.demo.domain.SysWarehouseUse;
import com.ruoyi.web.controller.service.ISysWarehouseUseService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * sys_warehouse_useController
 * 
 * @author ruoyi
 * @date 2023-01-02
 */
@Controller
@RequestMapping("/system/use")
public class SysWarehouseUseController extends BaseController
{
    private String prefix = "system/use";

    @Autowired
    private ISysWarehouseUseService sysWarehouseUseService;

    @RequiresPermissions("system:use:view")
    @GetMapping()
    public String use()
    {
        return prefix + "/use";
    }

    /**
     * 查询sys_warehouse_use列表
     */
    @RequiresPermissions("system:use:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysWarehouseUse sysWarehouseUse)
    {
        startPage();
        List<SysWarehouseUse> list = sysWarehouseUseService.selectSysWarehouseUseList(sysWarehouseUse);
        return getDataTable(list);
    }

    /**
     * 导出sys_warehouse_use列表
     */
    @RequiresPermissions("system:use:export")
    @Log(title = "sys_warehouse_use", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysWarehouseUse sysWarehouseUse)
    {
        List<SysWarehouseUse> list = sysWarehouseUseService.selectSysWarehouseUseList(sysWarehouseUse);
        ExcelUtil<SysWarehouseUse> util = new ExcelUtil<SysWarehouseUse>(SysWarehouseUse.class);
        return util.exportExcel(list, "sys_warehouse_use数据");
    }

    /**
     * 新增sys_warehouse_use
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存sys_warehouse_use
     */
    @RequiresPermissions("system:use:add")
    @Log(title = "sys_warehouse_use", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysWarehouseUse sysWarehouseUse)
    {
        return toAjax(sysWarehouseUseService.insertSysWarehouseUse(sysWarehouseUse));
    }

    /**
     * 修改sys_warehouse_use
     */
    @RequiresPermissions("system:use:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysWarehouseUse sysWarehouseUse = sysWarehouseUseService.selectSysWarehouseUseById(id);
        mmap.put("sysWarehouseUse", sysWarehouseUse);
        return prefix + "/edit";
    }

    /**
     * 修改保存sys_warehouse_use
     */
    @RequiresPermissions("system:use:edit")
    @Log(title = "sys_warehouse_use", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysWarehouseUse sysWarehouseUse)
    {
        return toAjax(sysWarehouseUseService.updateSysWarehouseUse(sysWarehouseUse));
    }

    /**
     * 删除sys_warehouse_use
     */
    @RequiresPermissions("system:use:remove")
    @Log(title = "sys_warehouse_use", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysWarehouseUseService.deleteSysWarehouseUseByIds(ids));
    }
}
